<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>修改个人资料</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/admin/css/admin.css">
  <script src="/static/layui/layui.js"></script>
</head>
<body>
  <div class="layui-container" style="padding-top:30px">
    <form class="layui-form">
      <input type="hidden" name="id" value="{$row.id}">
      <div class="layui-form-item">
          <label class="layui-form-label">昵称</label>
          <div class="layui-input-block">
            <input type="text" name="nickname" value="{$row.nickname}" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">头像</label>
          <div class="layui-input-block">
            <input type="hidden" name="avatar" id="icon" value="{$row.avatar}">
            <img src="{notempty name='row.avatar'}{$row.avatar}{else/} /static/admin/img/upimg.png {/notempty}" id="upload" class="layui-upimg layui-circle">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">登录账号</label>
          <div class="layui-input-block">
            <input type="text" disabled  value="{$row.username}" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">登录密码</label>
          <div class="layui-input-block">
            <input type="password" name="password" placeholder="" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">再次输入密码</label>
          <div class="layui-input-block">
            <input type="password" name="password_confirm" placeholder="" autocomplete="off" class="layui-input">
          </div>
        </div>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-filter="formCreate">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
      </div>
    </form>
  </div>

<script>
    //Demo
    layui.use(['form','upload','layer'], function(){
      var $ = layui.jquery,form = layui.form,upload = layui.upload;
      upload.render({
          elem: "#upload",
          field: "image",
          url: "/admin/upload",
          done: function(res){
              if(res.code==1){
                $('#upload').attr('src',res.src)
                $('#icon').val(res.src);
              }
          }
      });
    
     
      form.on('submit(formCreate)', function(data){
            $.post('/store/auth/change',data.field,function(res){
                if(res.code == 1){
                  layer.msg(res.msg,{
                      icon: 2
                  });
                  var index = parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.$.pjax({container: '#main',fragment: '#main'}).reload;
                }
                if(res.code ==0 ){
                    layer.msg(res.msg);
                }
            });
          
          return false;
        });
    });
    </script>
</body>
</html>
